<%
=begin
apps: none
platforms: kubernetes, ibm
id: get_started_charts_iks
=end %>

### Introduction

[IBM Cloud Kubernetes Service](https://www.ibm.com/cloud/container-services) is a managed Kubernetes service for production environments. Key features include intelligent scheduling, self-healing, horizontal scaling, service discovery and load balancing, automated rollouts and rollbacks, and secret and configuration management.

IBM Cloud Kubernetes Service makes it easy to configure and deploy a new Kubernetes cluster. Once you have your cluster running, you can use the IBM Cloud Catalog to deploy Bitnami's Kubernetes-ready applications into your cluster with a single click.

This tutorial will walk you, step by step, through the process of deploying Bitnami applications on a running IBM Cloud Kubernetes Service cluster.

### Assumptions and prerequisites

This tutorial assumes that:

* You have an IBM Cloud account. If you don't, [register for an IBM Cloud account](https://cloud.ibm.com/registration).
* You have provisioned an IBM Cloud Kubernetes Service cluster. If you haven't, [follow the instructions to create a new cluster](https://cloud.ibm.com/docs/containers?topic=containers-getting-started).
* You have installed the IBM Cloud Block Storage plugin for your Kubernetes cluster. If you haven't, [follow the installation steps for the IBM Cloud Block Storage plugin](https://cloud.ibm.com/docs/containers?topic=containers-block_storage#install_block).
* You have the [*kubectl* command line (*kubectl* CLI)](/kubernetes/get-started-kubernetes/#step-3-install-kubectl-command-line) installed and configured to work with your cluster.

For illustrative purposes, this guide will show you the steps to deploy the [Bitnami WordPress Helm chart](https://github.com/bitnami/charts/tree/master/bitnami/wordpress) on your IBM Cloud Kubernetes cluster. But WordPress is just an example: there are many other Helm charts available to choose from, and they're all equally easy to deploy by following the same steps.

### Step 1: Deploy WordPress through the IBM Cloud Catalog

: At the end of this step, you will have WordPress running in your IBM Cloud Kubernetes cluster.

Follow the steps below:

* Log in to your [IBM Cloud account](https://cloud.ibm.com/)
* Click the "Catalog" menu item in the top navigation bar.
* Select the "Software" tab of the catalog.
* Search for and select WordPress from the list of applications.

    <%= documentation_img '/images/img/platforms/kubernetes/catalog.png', 'WordPress selection' %>

* On the application deployment page, select your IBM Cloud Kubernetes Service cluster. Use the *default* namespace or add a custom namespace for the deployment.

    <%= documentation_img '/images/img/platforms/kubernetes/deployment.png', 'WordPress deployment' %>

* Scroll down to the application customization section and review the details of the deployment, such as the WordPress blog name, administrator name and email address, and administrator password. Enter a custom password, or leave it blank to have a random password generated.

    <%= documentation_img '/images/img/platforms/kubernetes/customization.png', 'WordPress deployment configuration' %>

* Read and agree to the license agreements. Click "Install" to begin the deployment.

IBM Cloud will now begin deploying WordPress to the Kubernetes cluster. This may take a few minutes and the status of the deployment will be visible in the workspace, as shown below.

<%= documentation_img '/images/img/platforms/kubernetes/status.png', 'WordPress deployment status' %>

In the resulting screen, click "View log" to see the deployment notes. Run the commands shown to obtain the service's public IP address and credentials (if randomly generated) to log in to WordPress. You can now access WordPress by launching your Web browser and browsing to the service address. You should see the front page of your blog with a sample post, as below:

<%= documentation_img '/images/img/platforms/common/tutorial-check-wordpress.png', 'WordPress home page' %>

### Step 2: Provide an external host for your application

> NOTE: Some applications require an extra step to provide a external host that the cluster can use to manage your application service. This guide uses OwnCloud as an example. This step is not required for WordPress. If you have deployed a WordPress Helm chart, skip this section and navigate to [step 3](#step-3-log-in-and-start-using-wordpress).

To provide an external host for your application, follow these instructions:

* Navigate to "Kubernetes -> Clusters" and click the cluster where you deployed the application.
* In the resulting screen, click the "Web terminal" button. It will open a terminal in the current tab. Click the maximize screen icon to start the terminal in a different tab.

    <%= documentation_img '/images/img/platforms/kubernetes/iks-cluster.png', 'Open the web terminal' %>

* [Install Helm](https://helm.sh/) in your cluster. Execute the following commands to install and configure the Helm CLI in the web terminal.

        $ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
        $ chmod 700 get_helm.sh
        $ USE_SUDO=false HELM_INSTALL_DIR=. ./get_helm.sh
        $ export PATH=`pwd`:$PATH

  > TIP: Check out the Helm official documentation to learn more about [how to install Helm 3 locally in your cluster](https://helm.sh/docs/intro/install/#from-script).

* Return to the IBM Cloud console and navigate to the "Schematics" section:

    <%= documentation_img '/images/img/platforms/kubernetes/iks-schematics.png', 'Navigate to the Schematics section' %>

* Select the workspace where your application is running. In the "Activity" section, click "View log" as shown below:

    <%= documentation_img '/images/img/platforms/kubernetes/iks-recent-activity.png', 'View logs' %>

* In the deployment notes you will see an error message similar to this:

        ###############################################################################
        ### ERROR: You did not provide an external host in your 'helm install' call ###
        ###############################################################################

* You will also find some commands to configure both the endpoint, the administration and the database password (if randomly generated). You should see a message similar to the following. Copy and execute the commands in the web console.

        This deployment will be incomplete until you configure ownCloud with a resolvable
        host. To configure ownCloud with the URL of your service:
        1. Get the ownCloud URL by running:
        NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        Watch the status with: 'kubectl get svc --namespace default -w owncloud'
        export APP_HOST=$(kubectl get svc --namespace default owncloud --template "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}")
        export APP_PASSWORD=$(kubectl get secret --namespace default owncloud -o jsonpath="{.data.owncloud-password}" | base64 --decode)
        export APP_DATABASE_PASSWORD=$(kubectl get secret --namespace default owncloud-mariadb -o jsonpath="{.data.mariadb-password}" | base64 --decode)

        2. Complete your ownCloud deployment by running:
        helm upgrade owncloud bitnami/owncloud \
        --set owncloudHost=$APP_HOST,owncloudPassword=$APP_PASSWORD,mariadb.db.password=$APP_DATABASE_PASSWORD

Enter the obtained URL in a web browser to access your application. Log in using the default username *user* and the password obtained in the step above.

<%= anchors 'step-2-log-in-and-start-using-wordpress' %>
### Step 3: Log in and start using WordPress

<%= partial 'platforms/common/login_wordpress_rooturi.md.erb' %>

<%= partial 'platforms/common/publish_update_wordpress.md.erb' %>

### Useful links

To learn more about the topics discussed in this tutorial, use the links below:

* [IBM Cloud](https://cloud.ibm.com)
* [Bitnami WordPress Helm chart](https://github.com/bitnami/charts/tree/master/bitnami/wordpress)
